package com.sdy.dcsb.biz.service.impl;

import com.sdy.dcsb.biz.mapper.SUserMapper;
import com.sdy.dcsb.biz.model.SUser;
import com.sdy.dcsb.biz.model.SUserJoint;
import com.sdy.dcsb.biz.service.SUserService;
import com.sdy.mvc.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author fb
 * @since 2019-10-08
 */
@Slf4j
@Service
public class SUserServiceImpl extends BaseServiceImpl<SUser> implements SUserService {
    @Autowired
    private SUserMapper sUserMapper;
    @Autowired
    private SUserService sUserService;

    /**
     * 获取登录的用户的信息-账号
     * @param request
     * @return
     */
    @Override
    public String getUser(HttpServletRequest request) {
        HttpSession session = request.getSession(true);
        if (session != null && session.getAttribute("user") != null) {
            SUserJoint sUserJoint = (SUserJoint)session.getAttribute("user");
            String user = sUserJoint.getUsername();
            return user;
        }else {
            return "dcsb";
        }
    }

}
